//
//  @ Project : Galaxy Star Trading System
//  @ File Name : ExecutionReportProcess.h
//  @ Date : 2014/9/5
//  @ Author :
//
//


#if !defined(_CEXECUTIONREPORTPROCESS_H_H)
#define _CEXECUTIONREPORTPROCESS_H_H

#include "../database/DataBase.h"

namespace GSTrader
{
	namespace TradeService
	{
		class CExecutionReportProcess
		{
		public:
			CExecutionReportProcess(CDataBase* pDataBase);
			virtual ~CExecutionReportProcess();

			int GetReportTime();

			CMsg* ProcessTrade(CTradeApi* pTradeApi, TradeCursor& pTrade, OrderCursor& pOrder);
			CMsg* ProcessOrder(CTradeApi* pTradeApi, OrderCursor& pOrder, int nOldStatus);

		private:
			CMsg* ProcessOrder(CTradeApi* pTradeApi, OrderCursor& pOrder);
			CMsg* OnTrade(CTradeApi* pTradeApi, TradeCursor& pTrade, OrderCursor& pOrder, bool bPartTraded);
			CMsg* OnNewOrder(CTradeApi* pTradeApi, OrderCursor& pOrder);
			CMsg* OnExpiredOrder(CTradeApi* pTradeApi, OrderCursor& pOrder);
			CMsg* OnCancelOrder(CTradeApi* pTradeApi, OrderCursor& pOrder, int nRejected);
			CMsg* OnOrderTraded(CTradeApi* pTradeApi, OrderCursor& pOrder, bool bPartTraded);
			CDataBase* m_pDataBase;
		};
	}
}

#endif //_CEXECUTIONREPORTPROCESS_H_H